package cn.com.sparkle.paxos.net.factory.netty;

import io.netty.channel.ChannelHandlerContext;

import com.google.protobuf.GeneratedMessage;

import cn.com.sparkle.paxos.net.factory.NetCloseException;
import cn.com.sparkle.paxos.net.factory.PaxosSession;

public class NettyPaxosSession extends PaxosSession {
	private ChannelHandlerContext ctx;
	public NettyPaxosSession(ChannelHandlerContext ctx){
		this.ctx = ctx;
	}
	@Override
	public void write(GeneratedMessage message) throws NetCloseException {
		ctx.writeAndFlush(message);
	}

	@Override
	public void closeSession() {
		ctx.close();
	}

}
